package momo.multitree.simulation;

import java.io.FileReader;

import momo.multitree.structure.Graph;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class SimulationFrameWork
{
	private Log log = LogFactory.getLog(SimulationFrameWork.class);
	
	//used to test one file
//	private int sizes[] = {5, 6, 7, 8, 9};
	private int sizes[] = {9};
	private String[] filenames;
	private double nonFW;
	
	public SimulationFrameWork() {
		nonFW = 0.5;
		filenames = new String[ sizes.length*100 ];
		int counter = 0;
		for(int i=0; i<sizes.length; i++)
		{
			for(int j=0; j<100; j++) {
//				filenames[ j + (counter*100) ] = sizes[i]+"_node_symmetric_noleaf_dataset_" + (j+1) +".txt";
				filenames[ j + (counter*100) ] = sizes[i]+"_node_symmetric_dataset_" + (j+1) +".txt";
//				filenames[ j + (counter*100) ] = sizes[i]+"_node_symmetric_noleaf_fw_"+nonFW+"_dataset_" + (j+1) +".txt";
			}
			counter ++;
		}
	}
	
	public SimulationFrameWork(int start, int end) {
		nonFW = 0.5;
		int length = end -start;
		filenames = new String[ sizes.length*length ];
		int counter = 0;
		for(int i=0; i<sizes.length; i++)
		{
			for(int j=0; j<length; j++) {
//				filenames[ j + (counter*length) ] = sizes[i]+"_node_symmetric_noleaf_dataset_" + (start+1+j) +".txt";
				filenames[ j + (counter*length) ] = sizes[i]+"_node_symmetric_dataset_" + (start+1+j) +".txt";
//				filenames[ j + (counter*length) ] = sizes[i]+"_node_symmetric_noleaf_fw_"+nonFW+"_dataset_" + (start+1+j) +".txt";
			}
			counter ++;
		}
	}
	
	public void run()
	{
		for(String filename: filenames)
		{
			try
			{
//				log.info("filename: "+filename);
				Graph g = new Graph(new FileReader("dataset/"+filename));
				
				SimulationWorker worker = new SimulationWorker(g);
				
//				worker.run();
				log.info(filename+", " + worker.run());
//				buffer.append(worker.run()+"\n\n");
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String args[])
	{
		SimulationFrameWork app = new SimulationFrameWork(80,100);
//		SimulationFrameWork app = new SimulationFrameWork();
		app.run();
	}
}//end of class SimulationFrameWork
